package com.flying.test1;

/**
 * @author 刘鹏飞
 * @ClassName GenericInterfaceTest
 * @Date 2024/12/23 23:18
 * @Created by 刘鹏飞
 * @Description
 */
public class GenericInterfaceTest {

    public static void main(String[] args) {

        // 创建泛型接口实例


        // 情况1: 只能传入 实现接口的具体泛型类型 String
        GenericInterface<String> generic=new GenericInterfaceImpl();
        String name = generic.getName("flying");
        System.out.println("name = " + name);



        // 情况2: 可以传入任意的泛型参数
        GenericInterface<Integer> generic1 = new GenericInterfaceImpl2<>();
        Integer name1 = generic1.getName(12);
        System.out.println("name1 = " + name1);

        GenericInterface<String> generic2 = new GenericInterfaceImpl2<>();
        String name2 = generic2.getName("你好");
        System.out.println("name2 = " + name2);

    }
}
